<!-- 角色分配 -->
<template>
  <div class='assign_role'>
    <dt-modal-edit ref='edit' :title='title' :label-width='90' okText='确定' :width='600'
      @ok='onOk'>

    </dt-modal-edit>
  </div>
</template>

<script>
  import assignRoleMgr from '../opt/assignRole'
  import userOrg from '@/biz/backStage/organizationManagement'

  export default {
    components: {},
    data() {
      return {
        title: '角色分配',
        selectionList: [],
        info: {
          selectionName: [],
          roleIds: []
        }
      };
    },
    methods: {
      show(data) {
        this.selectionList = data
        this.info.selectionName = data.map((item) => {
          return item.name
        })
        this.$refs.edit.show(assignRoleMgr.options(this), this.info)
      },
      hide() {
        this.$refs.edit.hide()
      },
      onOk() {
        let params = {
          roleIdList: this.info.roleIds,
          userIdList: this.selectionList.map((item) => {
            return item.userId
          }),
        }
        userOrg.roleGrant(params)
          .then((res) => {
            this.$Message.success('修改成功')
            this.$emit('success')
            this.hide()
          })
      }
    },

    mounted() {

    },
  }
</script>
<style lang='scss' scoped>
  .assign_role {}
</style>